package test.transferFile.codec;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * 文件传输编码解码工厂
 * @author Simple
 * @date 2013-6-25 上午09:41:39
 * @Description TODO
 */
public class TransferFileCodecFactory implements ProtocolCodecFactory {

  private final TransferFileEncoder encoder;

  private final CumulativeTransferFileDecoder decoder;

  public TransferFileCodecFactory(Charset charset) {
    this.encoder=new TransferFileEncoder(charset);
    this.decoder=new CumulativeTransferFileDecoder(charset);
  }

  @Override
  public ProtocolEncoder getEncoder(IoSession paramIoSession) throws Exception {
    return encoder;
  }

  @Override
  public ProtocolDecoder getDecoder(IoSession paramIoSession) throws Exception {
    return decoder;
  }
}
